import java.util.*;

/**
 * @author LKQ
 * @date 2022/6/14 18:28
 * @description
 */
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()) {
            int n = sc.nextInt();
            sc.nextLine();
            Map<String, Integer> map = new HashMap<>();
            Map<Integer, String> num = new HashMap<>();
            int idx = 0;
            for (int i = 0; i < n; i++) {
                String v = sc.next();
                num.put(idx++, v);
                map.put(v, 0);
            }
            int m = sc.nextInt();
            sc.nextLine();
            int cnt = 0;
            for (int i = 0; i < m; i++) {
                String v = sc.next();
                if (map.containsKey(v)) {
                    map.put(v, map.getOrDefault(v, 0) + 1);
                }else {
                    cnt++;
                }
            }
            for (Integer a: num.keySet()) {
                System.out.println(num.get(a) + " : " + map.get(num.get(a)));
            }
            System.out.println("Invalid : " + cnt);
        }
        sc.close();
    }
}
